package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.bottomsheet.BottomSheetDialog;

public class MainActivity18 extends AppCompatActivity {

    private View mImage;
    private BottomSheetDialog mSheetDialog;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity18.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main18 );
        initView();
        initViewAction();
    }

    private void initView() {

        mImage = (View) findViewById( R.id.button );
    }

    private void initViewAction() {

        mSheetDialog = new BottomSheetDialog( this );
        View view = getLayoutInflater().inflate( R.layout.dialog_bottom_sheet, null );
        mSheetDialog.setContentView( view );

        mImage.setOnClickListener( new OnClickListener() {

            @Override
            public void onClick( View v ) {

                if ( !mSheetDialog.isShowing() ) {
                    mSheetDialog.show();
                }
            }
        } );
    }
}